<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
cfc('core')->checklogin();
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$return['diy']=$this->plugin_setting('diy');
$return['setting']=$this->plugin_setting('basic');
$worker=pdo_get('jy_farmer_worker',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
 
if($_RQ['op']=='main'){
    $worker=pdo_get('jy_farmer_worker',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
    $member=pdo_get('core_members',array('id'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	if(!$worker){
		exi('找不到员工信息！','error','jy_newnong/myhome/');
	}
	//种植管理
	$list=pdo_getall('jy_farmer_plant',array('uniacid'=>$_SESSION['uniacid'],'status'=>1,'land_id >'=>0));
	$lclassify=$worker['lclassify_id'];
	$lclassify=explode(";",$lclassify);
	$lclassify=array_filter($lclassify);
	$plant_list=array();
	foreach($list as &$item){
		$item['lclassify_id']=pdo_getcolumn('jy_farmer_land',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['land_id']),'classify_id');
		if(in_array($item['lclassify_id'],$lclassify)){
			
			array_push($plant_list,$item);
		}
		
	}
	
	$return['worker']=$worker;
	$return['member']=$member;

	exi($return);
}
//修改员工信息
if($_RQ['op']=='set'){
	if($_RQ['postdata']){
		$postdata=get_postdata();
	
		$data=array(
				'name'=>$postdata['name'],
				);
		$worker_id=pdo_getcolumn('jy_farmer_worker',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'id');		
		if($worker_id){
			pdo_update('jy_farmer_worker',$data,array('id'=>$worker_id));
			exi('修改成功','','jy_newnong/worker_home/');		 
		}
	}
	$worker=pdo_get('jy_farmer_worker',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$return['worker']=$worker;
	exi($return);
	}